#include <fstream>
#include <ctime>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int t = clock(), x = 0;
    vector<int> arr;
    ifstream fin("m1_sorted");

    while (!fin.eof()) {
        fin >> x;
        arr.push_back(x);
    }
    for (int i = 0; i < arr.size() - 1; ++i) {
        for (int j = 0; j < arr.size() - i - 1; ++j) {
            if (arr[j] > arr[j + 1]) {
                x = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = x;
            }
        }
    }

    for (int i = 0; i < arr.size(); ++i) {
        cout << arr[i] << " ";
    }

    cout << endl << clock() - t;

    t = clock(), x = 0;
    vector<int> arr2;
    ifstream fin2("m2_reverse");

    while (!fin2.eof()) {
        fin2 >> x;
        arr2.push_back(x);
    }
    for (int i = 0; i < arr2.size() - 1; ++i) {
        for (int j = 0; j < arr2.size() - i - 1; ++j) {
            if (arr2[j] > arr2[j + 1]) {
                x = arr2[j];
                arr2[j] = arr2[j + 1];
                arr2[j + 1] = x;
            }
        }
    }

    for (int i = 0; i < arr2.size(); ++i) {
        cout << arr2[i] << " ";
    }

    cout << endl << clock() - t;

    t = clock(), x = 0;
    vector<int> arr3;
    ifstream fin3("m3_shuffle");

    while (!fin3.eof()) {
        fin3 >> x;
        arr3.push_back(x);
    }
    for (int i = 0; i < arr3.size() - 1; ++i) {
        for (int j = 0; j < arr3.size() - i - 1; ++j) {
            if (arr3[j] > arr3[j + 1]) {
                x = arr3[j];
                arr3[j] = arr3[j + 1];
                arr3[j + 1] = x;
            }
        }
    }

    for (int i = 0; i < arr3.size(); ++i) {
        cout << arr3[i] << " ";
    }

    cout << endl << clock() - t;

    return 0;
}
